package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.association.domain.TranslatorsAssociation;
import com.ruoyi.association.service.ITranslatorsAssociationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 中美翻译协会Controller
 * 
 * @author 王强
 * @date 2024-01-21
 */
@RestController
@RequestMapping("/frist/association")
public class TranslatorsAssociationController extends BaseController
{
    @Autowired
    private ITranslatorsAssociationService translatorsAssociationService;

    /**
     * 查询中美翻译协会列表
     */
    @PreAuthorize("@ss.hasPermi('frist:association:list')")
    @GetMapping("/list")
    public TableDataInfo list(TranslatorsAssociation translatorsAssociation)
    {
        startPage();
        List<TranslatorsAssociation> list = translatorsAssociationService.selectList(translatorsAssociation);
        return getDataTable(list);
    }

    /**
     * 导出中美翻译协会列表
     */
    @PreAuthorize("@ss.hasPermi('frist:association:export')")
    @Log(title = "中美翻译协会", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TranslatorsAssociation translatorsAssociation)
    {
        List<TranslatorsAssociation> list = translatorsAssociationService.selectList(translatorsAssociation);
        ExcelUtil<TranslatorsAssociation> util = new ExcelUtil<TranslatorsAssociation>(TranslatorsAssociation.class);
        util.exportExcel(response, list, "中美翻译协会数据");
    }

    /**
     * 获取中美翻译协会详细信息
     */
    @PreAuthorize("@ss.hasPermi('frist:association:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(translatorsAssociationService.selectById(id));
    }

    /**
     * 新增中美翻译协会
     */
    @PreAuthorize("@ss.hasPermi('frist:association:add')")
    @Log(title = "中美翻译协会", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TranslatorsAssociation translatorsAssociation)
    {
        return toAjax(translatorsAssociationService.insert(translatorsAssociation));
    }

    /**
     * 修改中美翻译协会
     */
    @PreAuthorize("@ss.hasPermi('frist:association:edit')")
    @Log(title = "中美翻译协会", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TranslatorsAssociation translatorsAssociation)
    {
        return toAjax(translatorsAssociationService.update(translatorsAssociation));
    }

    /**
     * 删除中美翻译协会
     */
    @PreAuthorize("@ss.hasPermi('frist:association:remove')")
    @Log(title = "中美翻译协会", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(translatorsAssociationService.deleteByIds(ids));
    }
}
